/*=========================================================================
The Impact of Denying a Wanted Abortion on Women and Children
Authors: Juliana Londoño-Vélez and Estefanía Saravia

Creation date: January 9th, 2024
--------------------------------------------------------------------------
Table 6 - Impacts on Household Composition and Marital Status
=========================================================================*/

use "$data/Final_Medellin_SisbenIV.dta", replace

	
global outcomes Tuvo_Hijos Numero_Hijos Vive_Abuelos Vive_Adulto_No_Pareja   N_Adulto_No_Pareja thogar Soltera Casada Divorciada_Viuda Educ_Pareja Madre_Soltera


mat a=J(11,4,.)
matrix rownames a =  $outcomes


local i=1
foreach var in $outcomes    {
	sum `var' if Niega==0
	mat 	a[`i',1] = r(mean)

	ivreghdfe `var'         (Niega=Mujer_Ponente)  , abs(oficina#time) cluster(id_juez) savefirst

	mat 	a[`i',2]  = _b[Niega]
	mat 	a[`i',3] = _se[Niega]

	mat 	a[`i',4] =e(N)


		
	local i=`i'+1
	}


mat lis a

	svmat2 a, rnames(outcome)
	
	drop if outcome==""
	
	rename a1 mean_nondenied
	rename a2 coef_femaleIV
	rename a3 se_femaleIV
	rename a4 N_femaleIV	
	
	
	keep outcome mean_nondenied coef_femaleIV se_femaleIV N_femaleIV
	
	
	order outcome mean_nondenied coef_femaleIV se_femaleIV N_femaleIV
	
	export excel using "$output/Tables paper matrices replication.xlsx", sheet("Table 6", modify) 
